package com.ruoyi.yuanliao.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.api.domain.SysDept;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.yuanliao.domain.TraceTransport;
import com.ruoyi.yuanliao.domain.TraceUserCrops;
import com.ruoyi.yuanliao.mapper.*;
import com.ruoyi.yuanliao.service.FarmerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 86182
* @description 针对表【trace_transport】的数据库操作Service实现
* @createDate 2023-05-20 10:57:18
*/
@Service
public class FarmerServiceImpl extends ServiceImpl<TraceTransportMapper, TraceTransport>
    implements FarmerService{

    @Autowired
    SysUserMapper sysUserMapper;

    @Autowired
    SysDeptMapper sysDeptMapper;

    @Autowired
    TraceUserCropsMapper traceCropsMapper;

    @Autowired
    TraceTransportMapper traceTransportMapper;

    @Override
    public List<SysUser> getAllDriverByDeptId(String deptId) {
        return sysUserMapper.selectUserByDeptId(deptId);
    }

    @Override
    public List<SysDept> getFactoryByDeptId(Integer deptId) {
        return sysDeptMapper.getFactoryByDeptId(deptId);
    }

    @Override
    public int addTransport(TraceTransport traceTransport) {
        int i = traceCropsMapper.updateByCropsId(traceTransport.getCropsId());
        return traceTransportMapper.insertSelective(traceTransport);
    }

    @Override
    public int saveCrops(TraceUserCrops traceCrops) {
        return traceCropsMapper.insert(traceCrops);
    }

    @Override
    public List<TraceUserCrops> getCropsByUsername(String username) {
        return traceCropsMapper.getCropsByUsername(username);
    }
}




